package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.TravelItineraryInfo;
import com.ktgj.customer.service.ITravelItineraryInfoService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 旅游行程详情Controller
 * 
 * @author ruoyi
 * @date 2021-11-10
 */
@ControllerAdvice
@RestController
@RequestMapping("/itineraryInfo")
public class TravelItineraryInfoController extends BaseController
{
    @Autowired
    private ITravelItineraryInfoService travelItineraryInfoService;

    /**
     * 查询旅游行程详情列表
     */
    //@PreAuthorize(hasPermi = "customer:info:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelItineraryInfo travelItineraryInfo)
    {
        startPage();
        List<TravelItineraryInfo> list = travelItineraryInfoService.selectTravelItineraryInfoList(travelItineraryInfo);
        return getDataTable(list);
    }

    /**
     * 导出旅游行程详情列表
     */
    //@PreAuthorize(hasPermi = "customer:info:export")
    @Log(title = "旅游行程详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelItineraryInfo travelItineraryInfo) throws IOException
    {
        List<TravelItineraryInfo> list = travelItineraryInfoService.selectTravelItineraryInfoList(travelItineraryInfo);
        ExcelUtil<TravelItineraryInfo> util = new ExcelUtil<TravelItineraryInfo>(TravelItineraryInfo.class);
        util.exportExcel(response, list, "旅游行程详情数据");
    }

    /**
     * 获取旅游行程详情详细信息
     */
    //@PreAuthorize(hasPermi = "customer:info:query")
    @GetMapping(value = "/{travelItineraryInfoId}")
    public AjaxResult getInfo(@PathVariable("travelItineraryInfoId") Long travelItineraryInfoId)
    {
        return AjaxResult.success(travelItineraryInfoService.selectTravelItineraryInfoById(travelItineraryInfoId));
    }

    /**
     * 新增旅游行程详情
     */
    //@PreAuthorize(hasPermi = "customer:info:add")
    @Log(title = "旅游行程详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelItineraryInfo travelItineraryInfo)
    {
        return toAjax(travelItineraryInfoService.insertTravelItineraryInfo(travelItineraryInfo));
    }

    /**
     * 修改旅游行程详情
     */
    //@PreAuthorize(hasPermi = "customer:info:edit")
    @Log(title = "旅游行程详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelItineraryInfo travelItineraryInfo)
    {
        return toAjax(travelItineraryInfoService.updateTravelItineraryInfo(travelItineraryInfo));
    }

    /**
     * 删除旅游行程详情
     */
    //@PreAuthorize(hasPermi = "customer:info:remove")
    @Log(title = "旅游行程详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{travelItineraryInfoIds}")
    public AjaxResult remove(@PathVariable Long[] travelItineraryInfoIds)
    {
        return toAjax(travelItineraryInfoService.deleteTravelItineraryInfoByIds(travelItineraryInfoIds));
    }
}
